package cn.nkpro.elcube.security.validate2;

import lombok.Getter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class NkAccessTokenAuthenticationToken extends AbstractAuthenticationToken {

    @Getter
    private String client;
    private String principal;
    private NkToken credentials;

    public NkAccessTokenAuthenticationToken(Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        super.setAuthenticated(false);
    }

    public NkAccessTokenAuthenticationToken(String client, String principal, NkToken credentials, Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        this.client = client;
        this.principal = principal;
        this.credentials = credentials;
        super.setAuthenticated(true);
    }

    @Override
    public NkToken getCredentials() {
        return credentials;
    }

    @Override
    public String getPrincipal() {
        return principal;
    }
}
